home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / poly.doc < prev    next >
Text File  |  1995-03-31  |  4KB  |  143 lines

  1. (Comp.sys.handhelds) 
  2. Item: 933 by wscott at ecn.purdue.edu 
  3. Author: [Wayne H Scott] 
  4.   Subj: Poly ver. 3 for HP-28  [and HP 48. -jkh] 
  5.   Date: Fri Oct 19 1990 07:55  
  6.  
  7. Several people have requested it so... 
  8.  
  9. Here is a version of my polynomial routines that will work on a HP-28. [&48] 
  10. My thanks to Craig Cantello who made the necessary changes to the programs. 
  11.  
  12. This package include the following programs. 
  13.  
  14. ZTRIM   Strip leading zeros from polynomial object. 
  15. IRT     Invert root program.  Given n roots it return a nth degree polynomial. 
  16. PDER    Derivative of a polynomial. 
  17. RDER    Derivative of a rational function. 
  18. PF      Partial Fractions.  (Handles multiple roots!) 
  19. FCTP    Factor polynomial 
  20. RT      Find roots of any polynomial 
  21. L2A     Convert a list to an array and back. 
  22. PADD    Add two polynomials 
  23. PMUL    Multiply two polynomials. 
  24. PDIV    Divide two polynomials. 
  25. EVPLY   Evalulate a polynomial at a point. 
  26. COEF    Given an equation return a polynomial list. 
  27.  
  28. These programs all work on polynomials in the follows form: 
  29.  
  30. 3*X^3-7*X^2+5 is entered as  { 3 -7 0 5 } 
  31.  
  32. so going down the list... 
  33.  
  34. The first program is FCTP. (factor polynomial) 
  35. When it is passed the cooeficients of a polynomial in a list it returns the 
  36. factor of that polynomal.  ex: 
  37.   
  38. 1: { 1 -17.8 99.41 -261.218 352.611 -134.106 } 
  39. FCTP 
  40. 3: { 1 -4.2 2.1 } 
  41. 2: { 1 -3.3 6.2 } 
  42. 1: { 1 -10.3 } 
  43.  
  44. This tells us that X^5-17.8*X^4+99.41*X^3-261.218*X^2+352.611*X-134.106 
  45. factors to (X^2-4.2*X+2.1)*(X^2-3.3*X+6.2)*(X-10.3) 
  46.   
  47. The next program is RT. (Roots) 
  48. If given a polynmoial it return its roots.  ex: 
  49.  
  50. 1: { 1 -17.8 99.41 -261.218 352.611 -134.106 } 
  51. RT 
  52. 5: 3.61986841536 
  53. 4: .58013158464 
  54. 3: (1.65, 1.8648056199) 
  55. 2: (1.65, -1.8648056199) 
  56. 1: 10.3 
  57.  
  58. Very Useful! 
  59.  
  60. These programs use the BAIRS program which performs Bairstow's method of 
  61. quadratic factors and QUD with does the quadratic equation. 
  62.  
  63. TRIM  is used to strip the leading zeros from a polynomial list. 
  64.  
  65. {0 0 3 0 7 } TRIM => { 3 0 7 } 
  66.  
  67. RDER  will give the derivative of a rational function. 
  68.  
  69. ie. d        x + 4                   -X^2 - 8*x + 31 
  70.     --   -------------  =   -------------------------------- 
  71.     dx   x^2 - 7*x + 3      x^4 - 14*x^3 + 55*x^2 - 42*x + 9 
  72.  
  73. 2: { 1 4 } 
  74. 1: { 1 -7 3 } 
  75. RDER 
  76. 2: { -1 -8 31 } 
  77. 1: { 1 -14 55 -42 9 } 
  78.  
  79. I don't know about you but I think it's useful. 
  80.  
  81. IRT will return a polynomial whose roots you specify. 
  82.  
  83. ie.  If a transfer function has zeros at -1, 1 and 5 the function 
  84.      is x^3 - 5*x^2 - x + 5 
  85.  
  86. 1: { -1 1 5 } 
  87. IRT 
  88. 1: { 1 -5 -1 5 } 
  89.  
  90. PDER will return the derivtive of a polynomial. 
  91.  
  92. .ie   The  d/dx (x^3 - 5*x^2 - x + 5) = 3*x^2 - 10*x - 1 
  93.  
  94. 1: { 1 -5 -1 5 } 
  95. PDER 
  96. 1: { 3 -10 -1 } 
  97.  
  98. PF will do a partial fraction expansion on a transfer function. 
  99.  
  100. .ie       s + 5            1/18    5/270    2/3      1/9       2/27 
  101.      ----------------- = ----- + ----- - ------- - ------- - ----- 
  102.      (s-4)(s+2)(s-1)^3   (s-4)   (s+2)   (s-1)^3   (s-1)^2   (s-1)  
  103.  
  104. 2: { 1 5 } 
  105. 1: { 4 -2 1 1 1 } 
  106. PF 
  107. 1: { 5.5555e-2 1.85185e-2 -.6666 -.11111 -.074074 } 
  108.  
  109. This program expects the polynomial of the numerator to be on level 2 and 
  110. a list with the poles to be on level 1.  Repeated poles are suported but 
  111. they must be listed in order.  The output is a list of the values of the  
  112. fraction in the same order as the poles were entered. 
  113.  
  114. PADD, PMUL, and PDIV are all obvious, they take two polynomial lists off 
  115. the stack and perform the operation on them. 
  116.  
  117. PDIV returns the polynomial and the remainder polynomial. 
  118.  
  119. L2A converts a list to and array. (and back) 
  120.  
  121. 1: { 1 2 3 } 
  122. L2A 
  123. 1: [ 1 2 3 ] 
  124. L2A 
  125. 1: { 1 2 3 } 
  126.  
  127. EVPLY evalutates and polynomial at a point. 
  128.  
  129. x^3 - 3*x^2 +10*x - 5 | x=2.5   = 16.875 
  130.  
  131. 2: { 1 -3 10 -5 } 
  132. 1: 2.5 
  133. EVPLY 
  134. 1: 16.875 
  135.  
  136. Wayne Scott             |  INTERNET:   wscott@en.ecn.purdue.edu 
  137. Electrical Engineering  |  BITNET:     wscott%ea.ecn.purdue.edu@purccvm 
  138. Purdue University       |  UUCP:      {purdue,pur-ee}!en.ecn.purdue.edu!wscott 
  139.  
  140. [Note: Wayne's original called the zero-trimming routine TRIM.  This conflicts 
  141. with Donnelly's TRIM function in his Tool Library.  So I renamed Wayn'e to 
  142. ZTRIM.  -jkh-] 
  143.